Skip to content

Conversation

@SamuelLHuber
Copy link

Summary

This PR adds Bun runtime support to @pyroscope/nodejs by updating the @datadog/pprof dependency to a Bun-compatible version.

Fixes #228

Problem

Bun is not currently supported because the upstream @datadog/pprof dependency crashes when loaded in Bun:

bun -e "import Pyroscope from '@pyroscope/nodejs'"
# => segfault in @datadog/pprof native addon

Solution

Updates the @datadog/pprof dependency to a fork that includes a pure JavaScript backend for Bun, avoiding the native addon crashes.

Upstream PR

This PR depends on: DataDog/pprof-nodejs#263

Once the upstream PR is merged and released, this dependency should be updated to the official npm package.

Changes

  • Updated package.json: Changed @datadog/pprof to use the Bun-compatible fork
  • Added tools/bun-smoke.mjs - End-to-end integration test for Bun
  • Added CI: Bun smoke tests on linux-x64, linux-arm64, darwin-arm64
  • CI gates releases on Bun smoke tests passing

Verification

Tested on:

  • ✅ Bun v1.3.5+
  • ✅ linux-x64, linux-arm64, darwin-arm64

Full Integration Test

The smoke test (tools/bun-smoke.mjs) validates:

  1. Import and lifecycle (init(), start(), stop())
  2. Express middleware endpoints (/debug/pprof/profile, /debug/pprof/heap)
  3. Continuous profiling export to Pyroscope
  4. Tags and labels
# Run the smoke test
yarn bun:smoke
# => {"ok":true,"heapBytes":...,"wallBytes":...,"ingestRequests":1}

Manual Test

# Lifecycle
bun -e "import pyroscope from '@pyroscope/nodejs'; pyroscope.init({appName:'test'}); pyroscope.start(); await pyroscope.stop(); console.log('ok')"
# => ok

# With express middleware
bun -e "
import express from 'express';
import Pyroscope from '@pyroscope/nodejs';
const app = express();
app.use(Pyroscope.expressMiddleware());
Pyroscope.init({appName:'test'});
Pyroscope.start();
console.log('Server with profiling ready');
"

Testing

  • Bun smoke tests pass on linux-x64
  • Bun smoke tests pass on linux-arm64
  • Bun smoke tests pass on darwin-arm64
  • Existing Node.js tests still pass
  • Update dependency once upstream PR is merged

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added CI coverage for the new feature
  • Tests pass locally and in CI
  • Documentation updated (will do after upstream merge)
  • Dependency updated to official package (after upstream merge)

Breaking Changes

None. This change only adds Bun support without affecting existing Node.js functionality.

@SamuelLHuber SamuelLHuber requested review from a team as code owners February 10, 2026 21:34
@CLAassistant
Copy link

CLAassistant commented Feb 10, 2026

CLA assistant check
All committers have signed the CLA.

@jake-kramer
Copy link
Contributor

Thanks for your contribution @SamuelLHuber. We wont be able to merge this in until the related upstream patch is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bun not supported as per upstream datadog/pprof

3 participants